package SubjectSearcher;

public class ProxySearcher extends Searcher{
    private Logger logger;
    private RealSearcher realSearcher;
    private AccessValidator validator;

    public ProxySearcher(Logger logger, RealSearcher realSearcher, AccessValidator validator) {
        this.logger = logger;
        this.realSearcher = realSearcher;
        this.validator = validator;
    }

    @Override
    public String doSearcher(String userId, String keyword) {
        String returnAns;
        validate(userId);
        returnAns=realSearcher.doSearcher(userId,keyword);
        log(userId);
        return returnAns;
    }

    public boolean validate(String userId){
        return validator.validate((userId));
    }

    public void log(String userId){
        logger.log(userId);
        return;
    }
}
